/* Represents a bar that holds the number of action points
 * 
 */

package gui.battle;

import java.awt.*;

import item.ship.Ship;

import javax.swing.*;

public class ActionPointBar extends JPanel {

	
	Ship ship; //the ship the ActionPointBar is for
	
	
	//1 param constructor that makes the ActionPointBar
	public ActionPointBar(Ship s){
		
		this.setMaximumSize(new Dimension(300, 40));
		this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
		
		ship = s;
		
		for(int i = 0; i < s.getActionPoints(); i++)
			this.add(new JLabel(new ImageIcon("assets\\images\\generalImages\\full_action_point.png")));
		
		for(int i = 0; i < s.getMaxActionPoints() - s.getActionPoints(); i++)
			this.add(new JLabel(new ImageIcon("assets\\images\\generalImages\\empty_action_point.png")));
		
	}//default constructor
	
	
	//updates the bar
	public void update(){
		
		this.removeAll();
		
		for(int i = 0; i < ship.getActionPoints(); i++)
			this.add(new JLabel(new ImageIcon("assets\\images\\generalImages\\full_action_point.png")));
		
		for(int i = 0; i < ship.getMaxActionPoints() - ship.getActionPoints(); i++)
			this.add(new JLabel(new ImageIcon("assets\\images\\generalImages\\empty_action_point.png")));
		
		this.repaint();
		this.revalidate();
	}//update
}//ActionPointBar
